package com.hngy.xpq.android_practice.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hngy.xpq.android_practice.R;
import com.hngy.xpq.android_practice.bean.Orders;
import com.hngy.xpq.android_practice.bean.Wallet;
import com.hngy.xpq.android_practice.merchant_main.Comm.CommMerchantActivity;

import java.util.List;

public class WalletAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private List<Wallet> list;
    CommMerchantActivity cma;

    public WalletAdapter(Context context, List<Wallet> list) {
        this.inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list == null ? 0 :list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        WalletAdapter.ViewHolder viewHolder;
        if (convertView == null){
            convertView = inflater.inflate(R.layout.item_wallet,null);
            viewHolder = new WalletAdapter.ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (WalletAdapter.ViewHolder) convertView.getTag();
        }
        Wallet w = (Wallet) getItem(position);
        viewHolder.item_wallet_des.setText(w.getDes());
        viewHolder.item_wallet_money.setText(w.getSingle_money());
        viewHolder.item_wallet_time.setText(w.getTime());
        return convertView;

    }

    class ViewHolder{
        TextView item_wallet_des,item_wallet_time,item_wallet_money;
        public ViewHolder(View v){
            item_wallet_des = v.findViewById(R.id.item_wallet_des);
            item_wallet_time = v.findViewById(R.id.item_wallet_time);
            item_wallet_money = v.findViewById(R.id.item_wallet_money);
        }
    }
}
